<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CrateShopOrderProductTable extends Migration
{

    public function up()
    {
        //订单商品规格(快照)
        Schema::create('shop_order_product', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('out_trade_no',23)->comment('订单号码');
            $table->unsignedInteger('product_id')->comment('产品ID');
            $table->string('product_title')->comment('产品名称');
            $table->unsignedInteger('spec_id')->comment('规格ID');
            $table->string('spec_name')->comment('规格名称');
            $table->unsignedDecimal('buy_price',10,2)->comment('购买价格');
            $table->integer('buy_count')->comment('购买数量');
            $table->unsignedDecimal('sub_total',10,2)->comment('小计');
            $table->timestamps();

        });
    }
    public function down()
    {
        Schema::dropIfExists('shop_order_product');
    }
}
